goog.provide('dkpoints.tests.stubFn');


/**
 * Returns a stub function that:
 *   - stores a flag showing whether or not it was called,
 *   - saves a reference to its arguments object,
 *   - returns the given return value when called.
 * @param {*} returnVal The value the mock function should return.
 * @return {function()} The stubbed function.
 */
dkpoints.tests.stubFn = function(returnVal) {
  var fn = function() {
    ++fn.timesCalled;
    fn.called = true;
    fn.args = arguments;
    return returnVal;
  };

  fn.timesCalled = 0;
  fn.called = false;
  fn.args = null;

  return fn;
};
